<?php

/**
 * Holds class Mvc_View
 *
 * @author Mark
 *
 * @package Library
 * @subpackage Mvc
 */

/**
 * View
 *
 * @todo write comment
 *
 * @author Mark
 */
abstract class Mvc_View implements Mvc_View_Interface {

	/**
	 * View file
	 * @var string $_file
	 */
	protected $_file;

//	/**
//	 * Templates
//	 * @var array $_template
//	 */
//	protected $_template = array();

	/**
	 * Variables
	 * @var array $_var
	 */
	protected $_var = array();
	
	/**
	 * Module name
	 *
	 * @var string $_module;
	 */
	protected $_module;
	
	/**
	 * Controller name
	 *
	 * @var string $_controller
	 */
	protected $_controller;
	
	
	/**
	 * Action name
	 *
	 * @var string $_action
	 */
	protected $_action;
	
	
	/**
	 * Template file
	 *
	 * @var string $_template
	 */
	protected $_template;
	
	
	public function __construct($module,$controller,$action,$template = null){
		$this->_module = $module;
		$this->_controller = $controller;
		$this->_action = $action;
		$this->_template = ($template === null) ? 'default' : $template;
	}
	
	/**
	 * Sets variables
	 *
	 * @param array $var
	 * @return void
	 */
	public function setVar($var){
		$this->_var = $var;
	}
	
	public function setTemplate($template){
		$this->_template = $template;
	}

//	/**
//	 * Renders template
//	 *
//	 * @param string $event
//	 * @return string
//	 */
//	public function getTemplate($event, $force = false) {
//		$result = '';
//		if($force) {
//			if(file_exists($event)) {
//				return $this->_render($event);
//			}
//		}
//
//		if(isset($this->_template[$event])) {
//			foreach($this->_template[$event] as $template) {
//				$result .= $this->_render($template);
//			}
//		}
//		return $result;
//	}

//	/**
//	 * Links template to event
//	 *
//	 * @param string $event
//	 * @param string $template
//	 * @throws Exception
//	 * @return Mvc_View (fluent interface)
//	 */
//	public function setTemplate($event, $template) {
//		if(!file_exists($template)) {
//			throw new Exception('Template ' . $template . ' does not exist');
//		}
//		$this->_template[$event][] = $template;
//		return $this;
//	}
}
